package com.suray.wcs.res.msgparse;


/**
 * @author Xuhang
 * @version 创建时间：2019年2月26日 下午3:05:25
 * 类说明
 */

import com.suray.wcs.res.enums.PalletStatus;
import com.suray.wcs.res.enums.RgvStatus;

/**
 * 基本信息心跳回复包
 *
 * @author Administrator
 */
public class HeartBaseResult extends ResultBase {

    /**
     * 当前坐标
     */
    private Integer currentLocation;
    /**
     * 当前小车行驶所在的段序号
     */
    private Integer curentSegment;
    /**
     * 当前段终点坐标
     */
    private Integer segmentLocation;
    /**
     * 返回当前条码值
     */
    private Integer curBarcode;
    /**
     * 车辆状态
     */
    private Integer rgvStatus;
    /**
     * 托板状态
     */
    private Integer palletStatus;
    /**
     * 换向状态
     */
    private Integer reserveStatus;
    /**
     * 行驶方向
     */
    private Integer driveDirection;
    /**
     * 电量
     */
    private Integer battery;

    /**
     * 基本信息返回
     */
    public HeartBaseResult(Integer deviceType, Integer deviceNo, Integer mode, Integer isSameMapVersion,
                           Integer currentLocation, Integer curentSegment, Integer segmentLocation, Integer curBarcode,
                           Integer rgvStatus, Integer palletStatus, Integer reserveStatus, Integer driveDirection, Integer battery,Integer statusMessage,
                           Integer barrierAtOne, Integer barrierAtTwo, Integer barrierAtThree, Integer barrierAtFour, Integer hasPallet, boolean isRight, Integer taskNo, Integer taskType, Integer taskResult, Integer cmdNo,
                           Integer cmdResult, Integer cmdExecuteResultParam) {
        this.deviceType = deviceType;
        this.deviceNo = deviceNo;
        this.mode = mode;
        this.isSameMapVersion = isSameMapVersion;
        this.currentLocation = currentLocation;
        this.curentSegment = curentSegment;
        this.segmentLocation = segmentLocation;
        this.curBarcode = curBarcode;
        this.rgvStatus = rgvStatus;
        this.palletStatus = palletStatus;
        this.reserveStatus = reserveStatus;
        this.driveDirection = driveDirection;
        this.battery = battery;
        this.statusMessage = statusMessage;
        this.barrierAtOne = barrierAtOne;
        this.barrierAtTwo = barrierAtTwo;
        this.barrierAtThree = barrierAtThree;
        this.barrierAtFour = barrierAtFour;
        this.offsetGroundCode = hasPallet;
        this.isRight = isRight;
        this.taskNo = taskNo;
        this.taskType = taskType;
        this.taskResult = taskResult;
        this.cmdNo = cmdNo;
        this.cmdResult = cmdResult;
        this.cmdExecuteResultParam = cmdExecuteResultParam;
    }


    @Override
    public Integer getDeviceNo() {
        return deviceNo;
    }

    @Override
    public Integer getMode() {
        return mode;
    }

    @Override
    public Integer getIsSameMapVersion() {
        return isSameMapVersion;
    }

    public Integer getRgvStatus() {
        return rgvStatus;
    }

    public void setRgvStatus(Integer rgvStatus) {
        this.rgvStatus = rgvStatus;
    }

    public Integer getCurrentLocation() {
        return currentLocation;
    }

    public Integer getCarStatus() {
        return rgvStatus;
    }

    public Integer getPalletStatus() {
        return palletStatus;
    }

    public Integer getDriveDirection() {
        return driveDirection;
    }


    void setCurrentLocation(Integer currentLocation) {
        this.currentLocation = currentLocation;
    }

    void setCarStatus(Integer carStatus) {
        this.rgvStatus = carStatus;
    }

    void setPalletStatus(Integer palletStatus) {
        this.palletStatus = palletStatus;
    }

    void setDriveDirection(Integer driveDirection) {
        this.driveDirection = driveDirection;
    }

    @Override
    public Integer getDeviceType() {
        return deviceType;
    }

    @Override
    public void setDeviceType(Integer deviceType) {
        this.deviceType = deviceType;
    }

    public Integer getCurentSegment() {
        return curentSegment;
    }

    public void setCurentSegment(Integer curentSegment) {
        this.curentSegment = curentSegment;
    }

    public Integer getSegmentLocation() {
        return segmentLocation;
    }

    public void setSegmentLocation(Integer segmentLocation) {
        this.segmentLocation = segmentLocation;
    }

    public Integer getCurBarcode() {
        return curBarcode;
    }

    public void setCurBarcode(Integer curBarcode) {
        this.curBarcode = curBarcode;
    }

    public Integer getReserveStatus() {
        return reserveStatus;
    }

    public void setReserveStatus(Integer reserveStatus) {
        this.reserveStatus = reserveStatus;
    }


    public Integer getBattery() {
        return battery;
    }

    public void setBattery(Integer battery) {
        this.battery = battery;
    }

    public Integer getX() {
        return MsgTransferUtil.parseToCoord(currentLocation).getX();
    }

    public Integer getY() {
        return MsgTransferUtil.parseToCoord(currentLocation).getY();
    }

    public Integer getZ() {
        return MsgTransferUtil.parseToCoord(currentLocation).getZ();
    }

    public Integer getsegmentLocationX() {
        return MsgTransferUtil.parseToCoord1(segmentLocation).getX();
    }

    public Integer getsegmentLocationY() {
        return MsgTransferUtil.parseToCoord1(segmentLocation).getY();
    }

    public void setBarrierAtOne(Integer barrierAtOne) {
        this.barrierAtOne = barrierAtOne;
    }

    public void setBarrierAtTwo(Integer barrierAtTwo) {
        this.barrierAtTwo = barrierAtTwo;
    }

    public void setBarrierAtThree(Integer barrierAtThree) {
        this.barrierAtThree = barrierAtThree;
    }

    public void setBarrierAtFour(Integer barrierAtFour) {
        this.barrierAtFour = barrierAtFour;
    }

    public void setHasPallet(Integer hasPallet) {
        this.offsetGroundCode = hasPallet;
    }

    @Override
    public String toString() {
        return "信息校验是否正确:" + isRight +
                ",\n结果接收时间:" + retTime +
                ",\n当前坐标:(" + getX() +","+ getY() + ","+ getZ() +
                "), \n当前小车行驶所在的段序号:" + curentSegment +
                ", \n当前段终点坐标:" + (segmentLocation == 65535 ? "无" :
                "("+ getsegmentLocationX() +","+ getsegmentLocationY() +"," + getZ() + ")" ) +
                ", \n当前条码值:" + curBarcode +
                ", \n车辆状态:" + RgvStatus.parseStatus(rgvStatus).getDescription() +
                ", \n托板状态:" + PalletStatus.parseStatus(palletStatus).getDescription() +
                ", \n换向状态:" + reserveStatus +
                ", \n行驶方向:" + driveDirection +
                ", \n电量:" + battery +
                ", \n任务序号:" + taskNo +
                ", \n任务类型:" + taskType +
                ", \n任务结果:" + taskResult +
                ", \n指令命令序号:" + cmdNo +
                ", \n指令执行结果:" + cmdResult +
                ", \n指令执行结果:" + cmdExecuteResult +
                ", \n指令结果参数:" + cmdExecuteResultParam +
                ", \n设备类型:小车" +
                ", \n设备号:" + deviceNo +
                ", \n模式:" + mode +
                ", \n地图版本是否一致:" + isSameMapVersion +
                ", \n故障描述:" + statusMessage +
                ", \n1方向障碍物感知:" + (barrierAtOne == 0 ? "正常" : (barrierAtOne == 1 ? "有故障物" : "未开启")) +
                ", \n2方向障碍物感知:" + (barrierAtTwo == 0 ? "正常" : (barrierAtTwo == 1 ? "有故障物" : "未开启")) +
                ", \n3方向障碍物感知:" + (barrierAtThree == 0 ? "正常" : (barrierAtThree == 1 ? "有故障物" : "未开启")) +
                ", \n4方向障碍物感知:" + (barrierAtFour == 0 ? "正常" : (barrierAtFour == 1 ? "有故障物" : "未开启"));
    }

}
